package com.example.a22310.myapplication.ViewModel.Club;


import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;

import com.example.a22310.myapplication.Adapter.MvvmAdapter;
import com.example.a22310.myapplication.Beans.ClubCourse;
import com.example.a22310.myapplication.Listener.ClubListener;
import com.example.a22310.myapplication.Model.ClubModel;
import com.example.a22310.myapplication.R;
import com.example.a22310.myapplication.databinding.FragmentClubCourseBinding;

import java.util.List;

public class ClubCourseViewModel implements ClubListener<ClubCourse> {
    private FragmentClubCourseBinding binding;
    private FragmentActivity activity;



    public ClubCourseViewModel(FragmentActivity activity, int binding, FragmentClubCourseBinding club_id){
        this.activity = activity;
        this.binding = binding;
        binding.setModel(this);
        ClubModel clubModel=new ClubModel();
        clubModel.courseList(club_id,ClubCourseViewModel.this);
    }

    @Override
    public void onSuccess(ClubCourse clubCourse) {
        if(clubCourse.getCode()!=404){
            List<ClubCourse.ClubcourselistBean> clubcoachlistBeen =  clubCourse.getClubcourselist();
            binding.recyclerViewClubCourse.setLayoutManager(
                    new LinearLayoutManager(activity));
            MvvmAdapter adapter = new MvvmAdapter(activity, R.layout.cardview_club_course,
                    clubcoachlistBeen, BR.course);
            binding.recyclerViewClubCourse.setAdapter(adapter);

        }

    }

    @Override
    public void onFailure() {
    }
}